<?php

class PropertyController extends Controller
{
    public $posts=3; // Search posts per one page

	public function actionIndex()
	{
        $this->layout='//layouts/index';
        $data= new Housing;
        $data=$data->searchFilter($this->posts);

//        $Criteria = new CDbCriteria(array("order" => "rate"));
//        $pages=new CPagination(Housing::model()->count($Criteria));
//        $pages->pageSize=5;
//        $pages->applyLimit($Criteria); // Делаем так, что бы не выбирались абсолютно все записи
//        $models = Housing::model()->findAll($Criteria);

        $this->render('properties', array(
            'models' => $data['models'],
            'pages' => $data['pages']
        ));
	}




    public function actionFilter($filter_location='',$filter_sublocation='',$filter_district='',$filter_type='',
                                 $filter_bedrooms='',$filter_bathrooms='',$filter_price_from='',$filter_price_to='',
                                 $filter_sort_by='',$filter_order='')
    {
        $this->layout='//layouts/index';
        $data= new Housing;
        $data=$data->searchFilter($this->posts,$filter_location,$filter_sublocation,$filter_district,$filter_type,
            $filter_bedrooms,$filter_bathrooms,$filter_price_from,$filter_price_to,
            $filter_sort_by,$filter_order);

        $this->render('properties', array(
            'models' => $data['models'],
            'pages' => $data['pages']
        ));
    }














//    public function actionFilter()
//    {
//        $this->layout='//layouts/index';
//        $this->render('faq');
//    }

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}